package day07;
//平均分

import java.util.Arrays;
import java.util.Scanner;

public class Avg {
    public static void main(String[] args) {
        //录入成绩.计算总分,平均分

        System.out.println(sumAvg(logData(6)));
    }
    //录入成绩
    public static double[] logData(int length){
        Scanner sc=new Scanner(System.in);
        double[] score=new double[length];
        for (int i=0;i<length;i++){
            score[i]=sc.nextDouble();
        }
        return score;

    }
    //求和,平均分
    public static double sumAvg(double[] d){
        //去最大,最小值
        double min=d[0];
        double max=d[0];
        double sum1=0.0;
        int min_index=0;
        int max_index=0;
        for (int i=0;i<d.length;i++){
            if(min>=d[i]){
                min_index=i;
            }
            if(max<d[i]){
                max_index=i;
            }
         //   sum1+=d[i];
        }
        d[min_index]=0;
        d[max_index]=0;
        System.out.println(Arrays.toString(d));
        for (int i=0;i<d.length;i++){
               sum1+=d[i];
        }
        sum1/= d.length-2;
        return sum1;
    }
    //求平均分
    public double avg(double sum,int length){
       // int
        return sum/length;
    }
    //
}
